package academic.ui.client.presenter;


import java.util.ArrayList;

import academic.ui.client.CheckoutServiceAsync;
import academic.ui.client.CustomerServiceAsync;
import ecommerce.soco.shared.GWT_CreditCard;
import ecommerce.soco.shared.GWT_Group;
import ecommerce.soco.shared.GWT_Purchase;
import ecommerce.soco.shared.GWT_Zone;


import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;
import com.gwtplatform.mvp.client.EventBus;
import com.gwtplatform.mvp.client.PresenterWidget;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.annotations.ContentSlot;
import com.gwtplatform.mvp.client.proxy.PlaceManager;
import com.gwtplatform.mvp.client.proxy.RevealContentHandler;

public class MyGroupsPresenter extends PresenterWidget<MyGroupsPresenter.MyView>
{

	private final CustomerServiceAsync service;
	
	private final PlaceManager placeManager;
	
	
	@ContentSlot
	public static final Type<RevealContentHandler<?>> slot = new Type<RevealContentHandler<?>>();
	
	
	@Inject 
	public MyGroupsPresenter(EventBus eventBus, MyView view,CustomerServiceAsync service,PlaceManager placeManager) {
		super(eventBus, view);
		this.placeManager=placeManager;
		this.service = service;
	}

	
	public interface MyView extends View {

		void showMyGroupsTab(ArrayList<GWT_Group> result);

	}
	
	@Override
	public void onReveal() {
		Log.debug("MyGroupsPresenter onReveal");
		service.getGroupsByCustomer(new AsyncCallback<ArrayList<GWT_Group>>() {

			@Override
			public void onFailure(Throwable caught) {
				// TODO Auto-generated method stub
				
			}

			@Override
			public void onSuccess(ArrayList<GWT_Group> result) {
				getView().showMyGroupsTab(result);
			}
			
		});
		
	}
	
	@Override
	public void onBind() {
		super.onBind();
		Log.debug("MyGroupsPresenter onBind");
	}
	
	@Override
	public void onUnbind() {
		super.onUnbind();
		
	}
	
	@Override
	public void onReset() {
		super.onReset();
		Log.debug("MyGroupsPresenter onReset");
	}
	
	

}
